/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gro.utilitarios;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import gro.utilitarios.Utilitarios.*;

/**
 *
 * @author Vicente
 */
public class Conexiones {

    private Connection con;
    private Statement stmt;

    public boolean crearConexion() {
        try {
            Class.forName(Global.pathDriver);
            con = DriverManager.getConnection(Global.direccionBase, Global.usuarioBase, Global.claveBase);
            stmt = con.createStatement();
            return true;
        } catch (Exception ex) {
            //Utilitarios.mensaje(ex.toString(), this.getClass().toString());
            return false;
        }
    }//crearConexion

    public void desconectar() {
        try {
            stmt.close();
            con.close();
        } catch (Exception ex) {
           // mensaje(ex.toString(), this.getClass().toString());
        }
    }//desconectar

    public boolean ejecutarSQL(String sql) {
        try {
            Statement stmt = con.createStatement();
            stmt.executeUpdate(sql);
        } catch (SQLException ex) {
           // mensaje(ex.toString(), this.getClass().toString());
            return false;
        }

        return true;
    }//ejecutarSQL
}
